Involver Developer Network : SML Syntax Guide
This page last changed on Aug 15, 2012 by yuriy.kalynovskiy@involver.com.
SML has a unique syntax that combines elements of the various sources it draws from. The building system will be familiar to folks who have used most other popular modern Content Management Systems. The result is a dynamic and flexible markup language that is interoperable with most other current markups and allows you to design and build fully interact-able websites on the leading Social Networking platforms. The most basic form for SML Tag Markup (used to call and configure Feature Blocks) is as follows: {% sml_tag attribute: "value" %}
The format for for Output Markup (used to output text strings from variables) is: {{ sml_variable | value: "display format" }}
You cannot nest Output Markup inside of Tag Markup. To use a variable as the value for an attribute in Tag Markup simply insert the variable name without quotes. WRONG: {% sml_tag attribute:"{{variable}}" %}
RIGHT: {% sml_tag attribute:variable %} Most SML applications will require a more sophisticated layout because they are outputting multiple chunks of data, each of which can can have their appearance structured and styled with HTML, CSS, and Javascript. Real examples can be far more complex with multiple chunks of data being pulled and inserted into a complex HTML/CSS framework which lends the output structure and style. They may also use if/then logic to output different sets of data depending on context (for instance, whether the user is a fan of the page). A generic example of that using an unordered list to organize a set of objects might look like: {% if is_page_fan %} {% sml_tag attribute: "value" %} <ul> {% for object in parent.content_items %} <li><a href="{{content_type.aspect_of_content}}"> {{ object.attribute | filter_for_inserted_item | second_filter }}</a> </li> {% endfor %} </ul> {% endsml_tag %} {% else %} <h2>You must be a fan to access this content.</h2> {% endif %} One of the first things that jumps out about this new example is the introduction of the “for” tag. 'for' is used for listing iterations, so in the example above 'for' would generate a series of list items, structured according to the html/sml layout contained in the space between 'for' and 'endfor'. Here's the same layout again, this time using markup from the ?rss_feed application as an example. Take some time to compare the two using the first as a map for the second. {% if is_page_fan %} {% rss_feed name:"myfeed" %} <ul> {% for blog_post in parent.content_items limit:5 %} <li><a href="{{blog_post.origin_url}}">{{ blog_post.title | truncate: 60 }}</a></li> {% endfor %} </ul> {% endrss_feed %} {% else %} <h3>You must be a fan to access this content.</h3> {% endif %} This example takes the rss feed “myfeed” and inserts the titles of 5 articles in a css-styled unordered list. Each of those titles is dynamically converted into a link back to the individual article urls. The source feeds that “myfeed” aggregates are set in the control panel. This is a perfect illustration of how SML as a whole functions. You use SML tags to insert an application and then configure it in the control panel for your tab or page. You then use HTML & SML to structure that application's outputs, CSS to style that output, and Javascript to add functionality as needed. |
![]() |
Document generated by Confluence on Feb 12, 2013 09:09 |